﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFrom2
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

   
        private void button3_Click(object sender, EventArgs e)
        {
            var uid = textBox1.Text;
            var pwd = textBox2.Text;

            using (SqlConnection connection = new SqlConnection(Dbhelper .conString ))
            {
                connection.Open();
                string sql = "select * from Users Where Username='{0}' and Password='{1}'";
                sql = string.Format(sql, uid, pwd);
                SqlCommand command = new SqlCommand(sql, connection);
                int result = (int)command.ExecuteScalar();
                if (result >0)
                {
                    MessageBox.Show("登录成功 ","提示");
                    date form3= new date();
                    this.Hide();
                    form3.Show();
                    
                }else
                {
                    MessageBox.Show("登录失败！","提示");
                
                }
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2();
            form2.Show();
        }
    }
}
